<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./style.css">

</head>

<body>
    <div id="app"></div>

    <script src="../react/react.development.js"></script>
    <script src="../react/react-dom.development.js"></script>
    <script src="../react/babel.min.js"></script>

    <script type="text/babel">
        function ProfileHeader(props) {
            return (
                <div>
                    <h2>用户昵称: {props.nickname}</h2>
                    <h2>用户等级: {props.level}</h2>
                </div>
            )
        }

        function Profile(props) {
            // props的值是  {nickname: 'kobe', level: '99'}
            return (
                <div>
                    {/*
                    下面两种方法调用组件效果是一样的，后者
                    */}
                    {/* <ProfileHeader nickname={props.nickname} level={props.level}/> */}
                    <ProfileHeader {...props} />
                    <ul>
                        <li>设置1</li>
                        <li>设置2</li>
                        <li>设置3</li>
                        <li>设置4</li>
                    </ul>
                </div>
            )
        }
        class APP extends React.Component {
            constructor(props) {
                super(props);

                this.state = {
                    nickname: "kobe",
                    level: 99
                }
            }

            render() {
                const {nickname, level} = this.state;

                return (
                    <div>
                        {/*
                        下面两种方法调用组件效果是一样的，后者用了扩展运算符 将this.state中的值都传递过去
                        */}
                        {/*<Profile  nickname={nickname} level={level}/>*/}
                        
                        <Profile {...this.state} />
                    </div>
                )
            }
        }

        ReactDOM.render(<APP />, document.getElementById('app'));

    </script>
</body>

</html>